package com.leetcode.LC_MED;

public class LC647 {
    int max = 0;

    public int countSubstrings(String s) {
        //中心拓展法
        char[] array = s.toCharArray();
        for (int i = 0; i < array.length; i++) {
            count(array, i, i);
            count(array, i, i + 1);
        }
        return max;
    }

    private void count(char[] array, int start, int end) {
        while (start >= 0 && end < array.length && array[start] == array[end]) {
            max++;
            start++;
            end--;
        }
    }
}
